// import com.alibaba.druid.sql.ast.SQLName_ptr;
// import com.alibaba.druid.sql.ast.SQLParameter_ptr;
// import com.alibaba.druid.sql.ast.SQLStatement_ptr;
// import com.alibaba.druid.sql.ast.SQLStatementImpl;
// import com.alibaba.druid.sql.ast.expr.SQLCharExpr_ptr;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "SQLCreateProcedureStatement.h"
#include "../SQLParameter.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../../../utils/listTran.h"
#include "../expr/SQLCharExpr.h"

  SQLCreateProcedureStatement::SQLCreateProcedureStatement() 
  {
    parameters = std::make_shared<std::list<SQLParameter_ptr>>();
  }

  // @Override
  void SQLCreateProcedureStatement::accept0(SQLASTVisitor_ptr visitor)
  {
    if (visitor->visit(SharedObject(SQLCreateProcedureStatement)))
    {
      acceptChild(visitor, definer);
      acceptChild(visitor, name);
      SQLObject_list_ptr tmp = ListTran::tran_class<SQLParameter, SQLObject>(parameters);
      acceptChild(visitor, tmp);
      acceptChild(visitor, block);
      acceptChild(visitor, comment);
    }
    visitor->endVisit(SharedObject(SQLCreateProcedureStatement));
  }

  SQLParameter_list_ptr SQLCreateProcedureStatement::getParameters()
  {
    return parameters;
  }

  void SQLCreateProcedureStatement::setParameters(SQLParameter_list_ptr parameters)
  {
    this->parameters = parameters;
  }

  SQLName_ptr SQLCreateProcedureStatement::getName()
  {
    return name;
  }

  void SQLCreateProcedureStatement::setName(SQLName_ptr name)
  {
    this->name = name;
  }

  SQLStatement_ptr SQLCreateProcedureStatement::getBlock()
  {
    return block;
  }

  void SQLCreateProcedureStatement::setBlock(SQLStatement_ptr block)
  {
    if (block != nullptr)
    {
      block->setParent(SharedObject(SQLCreateProcedureStatement));
    }
    this->block = block;
  }

  SQLName_ptr SQLCreateProcedureStatement::getAuthid()
  {
    return authid;
  }

  void SQLCreateProcedureStatement::setAuthid(SQLName_ptr authid)
  {
    if (authid != nullptr)
    {
      authid->setParent(SharedObject(SQLCreateProcedureStatement));
    }
    this->authid = authid;
  }

  BOOL_ptr SQLCreateProcedureStatement::isOrReplace()
  {
    return orReplace;
  }

  void SQLCreateProcedureStatement::setOrReplace(BOOL_ptr orReplace)
  {
    this->orReplace = orReplace;
  }

  SQLName_ptr SQLCreateProcedureStatement::getDefiner()
  {
    return definer;
  }

  void SQLCreateProcedureStatement::setDefiner(SQLName_ptr definer)
  {
    this->definer = definer;
  }

  BOOL_ptr SQLCreateProcedureStatement::isCreate()
  {
    return create;
  }

  void SQLCreateProcedureStatement::setCreate(BOOL_ptr create)
  {
    this->create = create;
  }

  string_ptr SQLCreateProcedureStatement::getJavaCallSpec()
  {
    return javaCallSpec;
  }

  void SQLCreateProcedureStatement::setJavaCallSpec(string_ptr javaCallSpec)
  {
    this->javaCallSpec = javaCallSpec;
  }

  BOOL_ptr SQLCreateProcedureStatement::isDeterministic()
  {
    return deterministic;
  }

  void SQLCreateProcedureStatement::setDeterministic(BOOL_ptr deterministic)
  {
    this->deterministic = deterministic;
  }

  BOOL_ptr SQLCreateProcedureStatement::isContainsSql()
  {
    return containsSql;
  }

  void SQLCreateProcedureStatement::setContainsSql(BOOL_ptr containsSql)
  {
    this->containsSql = containsSql;
  }

  BOOL_ptr SQLCreateProcedureStatement::isNoSql()
  {
    return noSql;
  }

  void SQLCreateProcedureStatement::setNoSql(BOOL_ptr noSql)
  {
    this->noSql = noSql;
  }

  BOOL_ptr SQLCreateProcedureStatement::isReadSqlData()
  {
    return readSqlData;
  }

  void SQLCreateProcedureStatement::setReadSqlData(BOOL_ptr readSqlData)
  {
    this->readSqlData = readSqlData;
  }

  BOOL_ptr SQLCreateProcedureStatement::isModifiesSqlData()
  {
    return modifiesSqlData;
  }

  void SQLCreateProcedureStatement::setModifiesSqlData(BOOL_ptr modifiesSqlData)
  {
    this->modifiesSqlData = modifiesSqlData;
  }

  SQLParameter_ptr SQLCreateProcedureStatement::findParameter(long hash)
  {
    for (SQLParameter_ptr param : *this->parameters)
    {
      if (param->getName()->nameHashCode64() == hash)
      {
        return param;
      }
    }

    return nullptr;
  }

  BOOL_ptr SQLCreateProcedureStatement::isLanguageSql()
  {
    return languageSql;
  }

  void SQLCreateProcedureStatement::setLanguageSql(BOOL_ptr languageSql)
  {
    this->languageSql = languageSql;
  }

  SQLCharExpr_ptr SQLCreateProcedureStatement::getComment()
  {
    return comment;
  }

  void SQLCreateProcedureStatement::setComment(SQLCharExpr_ptr comment)
  {
    if (comment != nullptr)
    {
      comment->setParent(SharedObject(SQLCreateProcedureStatement));
    }
    this->comment = comment;
  }

  string_ptr SQLCreateProcedureStatement::getWrappedSource()
  {
    return wrappedSource;
  }

  void SQLCreateProcedureStatement::setWrappedSource(string_ptr wrappedSource)
  {
    this->wrappedSource = wrappedSource;
  }
